<?php

if (isset ($_REQUEST["tal1"])) {
	$tal1= $_REQUEST["tal1"];

	echo $tal1; 	
}
else {$tal1=0; 
}
	session_start();
	
	if(!isset($_REQUEST["tal1"])) {
		session_destroy();
		session_start();	
	}
	
	if (isset ($_SESSION["res"])) {
	$res = $_SESSION["res"];
	
	
	if(isset ($_REQUEST["plus"])) {
		$res=$res+$tal1;
	}
	if(isset ($_REQUEST["minus"])) {
		$res=$res-$tal1;
	}
	if(isset ($_REQUEST["gange"])) {
		$res=$tal1*$res;	
	}
	
	if(isset ($_REQUEST["divider"])) {
		$res=$res/$tal1;
	}
		
	}
	else {
		$res=0;
	}

	echo"resultat: $res";
	$_SESSION["res"]=$res;
	


?>

<form action="sessionregner.php">
	<input type="text" name="tal1" />
    <input type="submit" name="plus" value="+" />
    <input type="submit" name="minus" value="-" />
    <input type="submit" name="gange" value="*" />
    <input type="submit" name="divider" value="/" />
</form>